package cn.nbt.busManage.model.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.NamedQueries;
import org.hibernate.annotations.NamedQuery;

import java.util.List;


@Entity
@Data
@EqualsAndHashCode(callSuper = true)
@Table(name = "role")
@NamedQueries({
        @NamedQuery(name = "Role.findByName",
                query = "SELECT r FROM Role r WHERE r.roleName = :query")
})
public class Role extends BaseEntity{
    @ManyToMany(cascade = CascadeType.PERSIST)
    @JoinTable(name = "role_menu",
            joinColumns = @JoinColumn(name = "role_id"),
            inverseJoinColumns = @JoinColumn(name = "menu_id"))
    private List<Menu> menus;
    @Column(name = "role_name")
    private String roleName;
    @Column(name = "status")
    private Integer status;
}
